<?php

class Album extends CI_Controller{
    
   
    
    //constructor
    function album(){
        
        parent::__construct();
        $this->load->library('upload');
        
   }
   
   ////////////////////////////////////////
    
    function index(){
        
 
        
        $this->load->model('Album_model');
        
        //check postingan dari upload form     
        $post = $this->input->post();
       
        if($post){
            
            // Validation rules. Format: set_rules(input_name, label_name, rules)
            $this->form_validation->set_rules('upload', 'Upload', 'required');
            $this->form_validation->set_rules('title','judul','required');
            
            if($this->form_validation->run()){
                
                $this->Album_model->do_upload();
                
            }
            else{
                
                echo 'masukan judul gambar';
            }
            
        }
       
        $data['images'] = $this->Album_model->get_images();
        
        $this->load->view('album_view',$data);
        
    }
    
    ////////////////////////////////////////////////////////////////////////////
    
    function delete_gambar(){
       
        $this->load->model('Album_model');
        
       $post = $this->input->post();
        
         if($post){
                
                
               $this->Album_model->delete_image($this->input->post('img_id'));
              
                redirect('album');
        
       }
   }
    ///////////////////////////////////////////////////////////////////////////
}
?>
